#ifndef __QUADTREETEST_H__
#define __QUADTREETEST_H__
/////////////////
//include
/////////////////
#include"Scene.h"
#include<ANX\Octree.h>
#include<ANX\Key.h>
#include<ANX\ContentManager.h>
#include<ANX\Manager.h>
/////////////////
//const
/////////////////

/////////////////
//class
/////////////////

class QuadTreeTest : public Scene
{
public:
	struct Player : public Object
	{
		Player()
		{

		}
		void Init()
		{
			Object::Init();
		}
		void ContentLoad(Device* device)
		{
			model = ContentManager::LoadModel("Resource/Knuckle/","Knuckle.pmd");
		}
		void Update()
		{
			float speed = 2.0f;
			if(Key::IsPushing(VK_RIGHT))
			{
				pos.x += speed;
			}
			if(Key::IsPushing(VK_LEFT))
			{
				pos.x -= speed;
			}
			if(Key::IsPushing(VK_UP))
			{
				pos.z += speed;
			}
			if(Key::IsPushing(VK_DOWN))
			{
				pos.z -= speed;
			}
		}
		void Draw(DeviceContext* device_context)
		{
			model->SetPos(pos);
			model->SetRot(rot);
			model->SetScale(scale);
			model->Draw(device_context);
		}
		
	};
	struct Enenmy : public Object
	{
		Enenmy(Vector3D pos)
		{
			this->pos = pos;
			direction = Vector3D(-1,0,0);
		}
		void Init()
		{
			Object::Init();
			int rand_max = 1000;
			pos = Vector3D((rand()%rand_max) - rand_max/2,0,(rand()%rand_max) - rand_max/2)+Vector3D(0,0,10000);
		}
		void ContentLoad(Device* device)
		{
			//model = ContentManager::LoadModel("Resource/Tuba/","tuba2.pmd");
		}
		void Update()
		{
			float speed = 2.0f;
			//pos+=Vector3D(rand()%10,rand()%10,rand()%10) * (((rand() % 2)*2)-1);
			rot.y = (rand()%10)/3.0f * (((rand() % 2)*2)-1);
			direction = Vector3D(-1,0,0).TransformMatrix(GetRotMatrix(0,rot.y,0)).Normalize();
			pos += direction*speed;
		}
		void Draw(DeviceContext* device_context)
		{
			model->SetPos(pos);
			model->SetRot(rot);
			model->SetScale(scale);
			model->Draw(device_context);
		}
		void SetModel(Model* model)
		{
			this->model = model;
		}
		Vector3D direction;
	};
	struct EnemyManager : public Manager
	{
		EnemyManager() : Manager(2000)
		{
			models = Array<Model*>(1);
		}
		void ContentLoad(Device* device)
		{
			models[0] = ContentManager::LoadModel("Resource/Tuba/","tuba2.pmd");
		}
	};
	QuadTreeTest();
	~QuadTreeTest();
	
	void Init();
	void ContentLoad(Device* device);
	void Update();
	void Draw(DeviceContext* device_context);
	
	Player player;
	EnemyManager enemy_manager; 
	
};
#endif __QUADTREETEST_H__
